﻿$(function() {

    $('#description .tabs li a').click(function() {
    
        $('#main #description .tabs li a').removeClass('active');
        var indexElem = $(this).index('#main #description .tabs li a');
        
        $('#description .tabs-inner .tab').hide();
        $('#description .tabs-inner .tab:eq(' + indexElem + ')').show();
        
        $(this).addClass('active');
    });
    
    $('#main #description .tabs-inner .tab .productDescription br:lt(2)').remove();
    

    $('#share ul li a').click(function() {
    
        var socialNetwork = $(this).attr('class');
        
        $('#sharemodal .socialbox').hide();
        $('#sharemodal .socialbox.' + socialNetwork ).show();
       
    });
    
    window.setTimeout(function() {
    
        $('#sku-select .Cor label').each(function() {
        
            var colorNameOriginal = $(this).text();
            var colorName = $(this).text();
            colorName = colorName.toLowerCase();
            colorName = colorName.replace(new RegExp('[áàâã]','gi'), 'a');
            colorName = colorName.replace(new RegExp('[éèê]','gi'), 'e');
            colorName = colorName.replace(new RegExp('[íìî]','gi'), 'i');
            colorName = colorName.replace(new RegExp('[óòôõ]','gi'), 'o');
            colorName = colorName.replace(new RegExp('[úùû]','gi'), 'u');
            colorName = colorName.replace(new RegExp('[ç]','gi'), 'c');
            colorName = colorName.replace(new RegExp('[\ \)\(\_]', 'gi'), '-');
            colorName = colorName.replace(new RegExp('[^a-z0-9\-]', 'gi'), '');
            
            $(this).css( 'background' , 'url(/arquivos/corprod_' + colorName + '.png) 0 0 no-repeat' ).attr( 'title' , colorNameOriginal );
        
        });
    
    },2000);
    
});